#include<iostream>
using namespace std;
int month[13] = { 0,31,28,31,30,31,30,31,31,30,31,30,31 };
bool check_year(int y)
{
	if (y % 400 == 0 || (y % 100 != 0 && y % 4 == 0))return 1;
	return 0;
}
bool check_date(int x)
{
	int y = x / 10000;
	int m = x % 10000 / 100;
	int d = x % 100;
	if (d == 0)return 0;
	if (m >= 13 || m <= 0)return 0;
	if (m == 2 && check_year(y)) {
		if (d > month[2] + 1)return 0;
		return 1;
	}
	return month[m] >= d ? 1 : 0;
}
int main()
{
	int ans = 0;
	for (int i = 19000101; i <= 99991231; i++) {
		if (check_date(i)) {
			int k = i;
			int a = k % 10000;
			int b = k / 10000;
			int sum1 = 0, sum2 = 0;
			while (a) {
				sum1 += a % 10;
				a /= 10;
			}
			while (b) {
				sum2 += b % 10;
				b /= 10;
			}
			if (sum1 == sum2) {
				//cout << i << endl;
				ans += sum1 == sum2 ? 1 : 0;
			}
		}
	}
	cout << ans << endl;
	return 0;
}